package com.wisdytech.linkdcs.common;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class BaseUtils {
	
	public static Map<String,Object> getRetResult(String key,Object value){
		Map<String,Object> result =new HashMap<>();
		result.put(key, value);
		return result;
	}
	
	
	/**
     * 
     * <p>Description: 获取唯一id</p>
     * @return
     */
    public static String getUUID(){
        return UUID.randomUUID().toString().replaceAll("\\-", "");
    }

  
    /**
     * 
     * @param file
     * @param filePath
     * @param fileName
     * @return
     */
    public static boolean uploadFile(byte[] file, String filePath, String fileName){

        File targetFile = new File(filePath);
        if(!targetFile.exists()){
            targetFile.mkdirs();
        }
        FileOutputStream out = null;
		try {
			out = new FileOutputStream(filePath+"/"+fileName);
			out.write(file);
			out.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return false;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}finally {
			if(null!=out) {
				try {
					out.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
		return true;

    }
    
    
}
